package com.zhitan.ems.app.patrol.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zhitan.ems.app.patrol.entity.PatrolPointEntity;
import com.zhitan.ems.app.patrol.mapper.PatrolPointMapper;
import com.zhitan.ems.app.patrol.service.PatrolPointService;
import com.zhitan.ems.app.patrol.vo.PatrolPointVO;
import com.zhitan.ems.framework.core.mp.base.BaseServiceImpl;
import com.zhitan.ems.framework.core.vo.VPage;
import com.zhitan.ems.framework.core.vo.VQueryKit;




@Service
public class PatrolPointServiceImpl extends BaseServiceImpl<PatrolPointMapper, PatrolPointEntity> implements PatrolPointService {
    
    @Override
	public VPage<PatrolPointVO> selectPatrolPointPage(IPage<PatrolPointVO> page, PatrolPointVO PatrolPoint) {
		return new VPage<PatrolPointVO>(baseMapper.selectPatrolPointPage(page,  VQueryKit.getQueryByMap(PatrolPoint)), page);	
	}
	
	  @Override
	public VPage<PatrolPointVO> selectPatrolPointMapPage(IPage<PatrolPointVO> page,Map<String, Object> params) {
		return new VPage<PatrolPointVO>(baseMapper.selectPatrolPointPage(page, params), page);	
	}
	
	
	@Override
	public List<PatrolPointEntity> queryList(Map<String, Object> params) {
		   QueryWrapper<PatrolPointEntity> queryWrapper =VQueryKit.getQueryWrapperByMap(params, PatrolPointEntity.class);
		   if(VQueryKit.isPage(params)) {
			   queryWrapper.last(VQueryKit.getPageLimit(params));
		    }
		   return this.list(queryWrapper);
	}
	@Override
	public VPage<PatrolPointEntity> queryPage(Map<String, Object> params) {
		   QueryWrapper<PatrolPointEntity> queryWrapper =VQueryKit.getQueryWrapper(params, PatrolPointEntity.class);
		   IPage<PatrolPointEntity> pages =this.page(VQueryKit.getPage(params), queryWrapper);
		   return VPage.create(pages);
	}
	@Override
	public long queryTotal(Map<String, Object> params) {
		  QueryWrapper<PatrolPointEntity> queryWrapper =VQueryKit.getQueryWrapperByMap(params, PatrolPointEntity.class);
		  return this.count(queryWrapper);
	}
	@Override
	public PatrolPointEntity queryByQrCode(String qrCode) {
		   QueryWrapper<PatrolPointEntity> queryWrapper=new QueryWrapper<PatrolPointEntity>();
		   queryWrapper.eq("qr_code", qrCode);
		   return this.getOne(queryWrapper);
	}
}